﻿@using Kybotech.Paragon
@model Kybotech.Paragon.Visit
@{

    Kybotech.Paragon.Visit selectedVisit;
    if (Model == null)
    {
        selectedVisit = new Kybotech.Paragon.Visit();
        selectedVisit.Products = new List<Product>();
    }
    else{ selectedVisit = Model;}

    bool visitIsCollection = false;
    foreach (var item in selectedVisit.Products)
    {
        if (item.Description.ToLower().Contains("collection"))
        {
            visitIsCollection = true;
        }
    }
    string weight = "";
    string unloadTime = "";
    string volume = "";
    bool isCollection = false;
    if (visitIsCollection
        && (selectedVisit.DeliverMeasure1 + selectedVisit.DeliverMeasure2 + selectedVisit.DeliverVariableTime) == 0)
    {
        weight = selectedVisit.CollectMeasure1.ToString();
        volume = selectedVisit.CollectMeasure2.ToString();
        unloadTime = selectedVisit.CollectVariableTime.ToString();
        isCollection = true;
    }
    else
    {
        weight = selectedVisit.DeliverMeasure1.ToString();
        volume = selectedVisit.DeliverMeasure2.ToString();
        unloadTime = selectedVisit.DeliverVariableTime.ToString();
        isCollection = false;
    }
}
            <div class="row-fluid">
                <fieldset>
                    <legend>Date filter</legend>
                    <div class="row-fluid">
                        <form method="POST" id="frmGetAvailableDate">
                            <div class="span2"><input name="IsOutStock" value="@(ViewBag.IsOutStock)" type="hidden" />
                                Start date: 
                            </div>
                            <div class="span3">
                                <div id="datetimepicker1" class="input-append">
                                    <input data-format="MM/dd/yyyy" type="text" name="startDate" value="@(ViewBag.IsOutStock==1?DateTime.Now.AddDays(10).ToString("MM/dd/yyyy"): DateTime.Now.ToString("MM/dd/yyyy"))" id="startDate" style="width: 100px;" required="required">
                                    <span class="add-on">
                                        <i data-time-icon="icon-time" data-date-icon="icon-calendar" class="icon-calendar"></i>
                                    </span>
                                </div>
                            </div>
                            <div class="span3">Number of days to query: </div>
                            <div class="span1"><input name="noOfDay"type="text" style="width:50px;" class="input-block-level" value="14"/>
                            </div>
                            <div class="span3"><button type="submit" class="btn btn-primary pull-right">Get available date</button> </div>      
                        </form>
                    </div>
                </fieldset>
            </div>
                    
            <div class="row-fluid">
                <fieldset>
                    <legend>Visit info</legend>
                    <div class="row-fluid" id="divVisitInfo">
                        <form id="frChangeVisitInfo">
                        <div class="span1">Weight</div>
                        <div class="span1">
                            <input name="weight" type="text" style="width:60px"  class="input-block-level" value="@weight" onchange="VisitInfoChanged()"/>
                        </div>
                        <div class="span1">Volume</div> 
                        <div class="span1">
                            <input  name="volume" type="text" style="width:60px"  class="input-block-level"value="@volume" onchange="VisitInfoChanged()"/>
                        </div>
                        <div class="span1">Vehicle</div> 
                        <div class="span1">
                            <input  name="vehicle" type="text" style="width:60px"  class="input-block-level"value="@selectedVisit.RigidTypeAcceptability" onchange="VisitInfoChanged()"/>
                        </div>
                        <div class="span1">Unload time</div> 
                        <div class="span1">
                            <input  name="unloadTime"type="text" style="width:60px"  class="input-block-level"value="@unloadTime" onchange="VisitInfoChanged()"/>
                        </div>
                        <div class="span2">
                            <input  type="checkbox" name="isCollection" id="isCollection" @(isCollection?"checked=checked":"") value="1" onchange="VisitInfoChanged()"> Is collection
                        </div>
                        <div class="span2">
                            <button type="submit" class="btn btn-primary pull-right" >Change visit info</button>
                        </div>
                        </form>
                    </div>
                    <div class="row-fluid">
                        Customer: @ViewBag.CustomerName
                    </div>                        
                    <div class="row-fluid"  style="height:70px">Address: @selectedVisit.Address <br /> @selectedVisit.GeoCode</div>
                    <div class="row-fluid" style="@((bool)ViewBag.IsNewOrder ? "display:none" : "")">
                        <div class="span2">Special Instruction:</div>
                        <div class="span8"><textarea name="specialInstruction" id="specialInstruction"rows="3" class="controls" style="width: 100%">@selectedVisit.SpecialInstructions</textarea></div>
                        <div class="span2"><a class="btn btn-success" onclick="SaveSpecialInstruction($('#specialInstruction').val())">Save</a></div>
                    </div>
                    <div class="row-fluid">
                        <div class="span3">Select time slot: <span id="SelectedTimeSlot"></span></div>
                        <div class="span1">Phone:</div>
                        <div class="span3"><input type="text" style="width:200px"  class="input-block-level" value="@selectedVisit.Telephone"/></div>
                        <div class="span5"> <button type="button" class="btn btn-primary pull-right" onclick="SelectAvailableDate()">Select Date</button></div>
                    </div>
                </fieldset>
            </div>
    <div class="row-fluid" id="ListAvailableDate">
        <div style="background-color:#efb3b3; height:392px; text-align:center;">
            Can't find any order item allow pick a date
        </div>
    </div>